
// 弹窗构造函数
function bDialog(){
	this.win = $(
				'<div class="bg dialog">\
					<div class="box">\
						<div class="head">\
							<div class="title"></div>\
							<div class="close">×</div>\
						</div>\
						<div class="content"></div>\
					<div>\
				<div>');
}
bDialog.prototype = {
	open(conf){
		this.conf = conf;
		this.setDefault();
		this.show();
	},
	show(){
		this.setCss();
		this.setContent();
		this.setEvent();
		$('html').append(this.win);
		this.win.hide();
		this.win.fadeIn(200);
	},
	setDefault(){
		//this.conf.width = this.conf.width?this.conf.width: "80%";
		//this.conf.height = this.conf.height?this.conf.height: "200px";
	},
	setContent(){
		this.win.find('.head .title').text(this.conf.title?this.conf.title:'提示');
		this.win.find('.content').html(this.conf.html);
	},
	setEvent(){
		var that = this;
		this.win.on('click', '.close', function(){
			that.win.remove();
		});
	},
	setCss(){
		this.win.css({
			position: 'fixed',
			left: '0px',
			right: '0px',
			top: '0px',
			bottom: '0px',
			backgroundColor: '#000A',
		});
		
		this.win.find('.box').css({
			minWidth: '35%',
			width: this.conf.width,
			height: this.conf.height,
			backgroundColor: '#FFF',
			position: 'absolute',
			left: '50%',
			top: '50%',
			transform: 'translate(-50%, -50%)',
			boxShadow: '0px 0px 20px #000a',
			overFlow: 'hidden',
		});
		this.win.find('.head').css({
			height: '50px',
			lineHeight: '50px',
			paddingLeft: '10px',			
			boxShadow: '0px 0px 10px #0004',
			color: '#1B1C1E',
			fontWeight: 'bold',
			fontSize: '18px',
		});
		this.win.find('.head .title').css({
			float: 'left',
		});
		this.win.find('.head .close').css({
			margin: '10px 10px',
			width: '30px',
			height: '30px',
			textAlign: 'center',
			lineHeight: '30px',
			float: 'right',
			color: '#FFF',
			fontSize: '20px',
			backgroundColor: '#D35157',
			borderRadius: '15px',
		});
		this.win.find('.content').css({
			fontSize: '18px',
			textAlign: 'center',
			padding: '15px',
		});
	}
};

